extends "../buleisite-1/buleisite-1.gd"


func _extInit():
	._extInit()
	if isInManual():
		addSkill(sk1t1[1], sk1t1[0])
		addSkill(sk1t2[1], sk1t2[0])
	elif sk1 != 0:
		doChoiceSkill1()
	lv = 2             #等级的设置
var sk1t1 = ["弹种切换·1", "可在角色面板切换炮击弹药种类：穿甲弹(弹道速度极快，附带30%装甲穿透)，高爆弹(弹道速度极慢，但会对目标周围2格的敌人产生130%的溅射炮击伤害)"]
var sk1t2 = ["弹种切换·2", "可在角色面板切换炮击弹药种类：穿甲弹(弹道速度极快，伤害提高30%)，高爆弹(弹道速度极慢，但会对目标周围3格的敌人产生80%的溅射炮击伤害)"]

var ammoType = 1
func doChoiceSkill1():
	# var sk = get("sk1t%d"%sk1)
	# addSkill(sk[1], sk[0])
	if sk1 == 1:
		addSkill("可在角色面板切换炮击弹药种类：\n[color=#DC143C]穿甲弹[/color](弹道速度极快，附带20%装甲穿透)\n[color=#DC143C]高爆弹[/color](弹道速度极慢，但会对目标周围2格的敌人产生100%的溅射炮击伤害)", sk1t1[0])
	if sk1 == 2:
		addSkill("可在角色面板切换炮击弹药种类：\n[color=#DC143C]穿甲弹[/color](弹道速度极快，伤害提高20%)\n[color=#DC143C]高爆弹[/color](弹道速度极慢，但会对目标周围3格的敌人产生50%的溅射炮击伤害)", sk1t2[0])

func chaInfo(cha):
	.chaInfo(cha)
	var charaInfos = []
	for i in sys.get_node("/root/topUi").get_children():
		if i.name.find("charaInfoMsg") > -1:charaInfos.append(i)
	var charaInfo = charaInfos.pop_back()
	var btnBoxR = charaInfo.get_node("btnBoxR")
	if ammoType == 1:
		utils.createItemButton(btnBoxR, self, "弹种：穿甲弹", "switchAmmoType", [], null, null, true)
	else:
		utils.createItemButton(btnBoxR, self, "弹种：高爆弹", "switchAmmoType", [], null, null, true)

func switchAmmoType(btn):
	if ammoType == 1:
		ammoType = 2
		if btn != null:
			btn.text = "弹种：高爆弹"
		atkFlySpd = 200
	else:
		ammoType = 1
		if btn != null:
			btn.text = "弹种：穿甲弹"
		atkFlySpd = 3000

func _onBattleStart():
	._onBattleStart()
	resetAtkFlySpd()

func resetAtkFlySpd():
	if ammoType == 1:
		atkFlySpd = 3000
	else:
		atkFlySpd = 200

func _onAtkInfo(atkInfo):
	._onAtkInfo(atkInfo)
	if atkInfo.atkType == sys.AtkType.GUN:
		if ammoType == 1:
			#穿甲弹
			if sk1 == 1:
				atkInfo.penL += 0.3
			else:
				atkInfo.factor += 0.3

func onAtkEnd(atkInfo):
	.onAtkEnd(atkInfo)
	if atkInfo.atkType == sys.AtkType.GUN and atkInfo.skill == "炮击" and ammoType == 2:
		#高爆弹
		if sk2 == 1:
			var chas = getCellChas(atkInfo.hitCha.cell, 2, 1)
			chas.erase(atkInfo.hitCha)
			for i in chas:
				azurHurtChara(i, atkInfo.finalDmg*1.3, sys.HurtType.WEAPON, sys.AtkType.GUN, "高爆弹")
		else:
			var chas = getCellChas(atkInfo.hitCha.cell, 3, 1)
			chas.erase(atkInfo.hitCha)
			for i in chas:
				azurHurtChara(i, atkInfo.finalDmg*0.8, sys.HurtType.WEAPON, sys.AtkType.GUN, "高爆弹")

func doNormalAtk(cha):
	# var d:Eff = newEff(atkEff, sprcPos)
	# d._initFlyCha(cha, atkFlySpd)
	# _onNormalAtk(cha)
	# yield (d, "onReach")
	var eff = createCustEff(position, "eff/bodaodan", 0, false, 0.5, Vector2(-30, -30))
	eff._initFlyCha(cha, atkFlySpd)
	yield (eff, "onReach")
	atkInfo.atkCha = self
	atkInfo.rate = 1
	atkInfo.isCri = false
	atkInfo.canCri = true
	atkInfo.atkVal = mainDmg * (1 + att.gun)
	atkInfo.hurtVal = atkInfo.atkVal
	atkInfo.hurtType = sys.HurtType.WEAPON
	atkInfo.atkType = sys.AtkType.GUN
	atkRun(cha)